
import strategies from '@/components/detail/strategies';

export const isEmptyObject = obj => Object.keys(obj).length === 0;

export const sortCustom = sortType => function (a, b) {
  const aVal = strategies.find(item => item.strategyName === a[sortType]);
  const bVal = strategies.find(item => item.strategyName === b[sortType]);
  return aVal.order - bVal.order;
};

export const sortNumber = property => function (a, b) {
  const value1 = a[property];
  const value2 = b[property];
  return value1 - value2;
};

export const sortDateStr = property => function (a, b) {
  const value1 = new Date(a[property]).getTime();
  const value2 = new Date(b[property]).getTime();
  return value1 - value2;
};
